<template>
    <view class="page-wrap">
        <Position type=""></Position>
        <view class="content">
            <view v-if="showLeft" class="left hiddenScroll">
                <view class="item" @tap="handClick(index)" :class="{ active: index == current }"
                    v-for="(item, index) in list" :key="index">
                    <view class="txt">{{ item.title }}</view>
                </view>
            </view>
            <view class="right">
                <basePoint v-if="modelForm" :modelForm="modelForm" :configs="options" :intoIndex="intoIndex"
                    @getForm="getForm"></basePoint>
            </view>
        </view>

        <view class="btns">
            <view class="btn save">存草稿</view>
            <view class="btn sub" @tap="submit">确认提交</view>
        </view>
    </view>
</template>

<script>


import basePoint from './components/basePoint/index.vue'
import model from './assets/model'
export default {
    components: { basePoint },
    computed: {

    },
    data() {
        return {
            type: 'basePoint',
            list: [

            ],
            current: '',
            intoIndex: '',
            form: null,
            modelForm: null,
            showLeft: true,
            options: [],

        }
    },
    onLoad(options) {
        this.getModel(2);
    },
    methods: {
        getModel(type) {
            let { showLeft, options, form, title } = model[type]
            this.modelForm = form;
            this.showLeft = showLeft;
            this.options = options
            this.list = options.map(v => {
                return { title: v.title }
            })
            wx.setNavigationBarTitle({
                title
            })
        },
        handClick(index) {
            this.current = index
            this.intoIndex = 'slot' + index
        },
        getForm(val) {
            this.form = val;
        },
  submit() {
            wx.showModal({
                title: '提示',
                content: '是否确定提交全部工单和附件图片？',
                success:(res)=> {
                    if (res.confirm) {
                         console.log('用户点击确定',JSON.stringify(this.form))
                    } else if (res.cancel) {
                        console.log('用户点击取消')
                    }
                }
            })
        }
    }
}
</script>

<style src="./assets/index.scss" lang="scss" scoped></style>


